package com.bsdsma.fengheguaiapp.restcontroller;

import com.bsdsma.fengheguaiapp.service.FileService;
import com.bsdsma.fengheguaiapp.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
@RequestMapping(value = "/api/files")
public class FileRestController {

    @Autowired
    private FileService fileService;

    @PostMapping
    @ResponseStatus(value = HttpStatus.CREATED)
    public Map<String, Object> upload(MultipartFile file){
        return ResultUtils.ok(fileService.upload(file));
    }

}
